﻿#region namespaces

using System.Diagnostics;
using NLog;
using Tools.BaseX;

#endregion

namespace ZOIL.DataBackend.BaseX
{
    [DebuggerDisplay("Database {Name}")]
    public sealed partial class Database
    {
        #region Logger

        // ReSharper disable InconsistentNaming
        private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
        // ReSharper restore InconsistentNaming

        #endregion

        #region private fields

        /// <summary>
        ///     Configuration for this database instance.
        ///     Contains information like login for database and the used serializer
        ///     Is passed in the <see cref="Database(DatabaseConfiguration)" />
        /// </summary>
        public readonly DatabaseConfiguration DbConfig;

        /// <summary>
        ///     Connection to the BaseX server
        /// </summary>
        private readonly BaseXClient _client;

        /// <summary>
        ///     Contains the buffered objects from the database
        /// </summary>
        private readonly DatabaseObjectManager _localDbObjects = new DatabaseObjectManager();

        #endregion

        #region helper properties/fields

        public string DatabaseName
        {
            get { return DbConfig.DatabaseName; }
        }

        public ISerializer Serializer
        {
            get { return DbConfig.Serializer; }
        }

        /// <summary>
        ///     For debugging
        /// </summary>
        public string Name { get; set; }

        #endregion
    }
}